<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

<%--@elvariable id="messages" type="java.util.List<sk.xorty.domain.Message>"--%>

<html>
<head>
    <title>Message List</title>
</head>
<body>
    <a href="<c:url value="/login.jsp" />">Login</a>
    <hr />
    <a href="<c:url value="/j_spring_security_logout" />">Logout</a>
    <hr />
    <h2>Welcome <security:authentication property="name" /></h2>

    <security:authentication property="authorities" var="authorities" />
    <c:forEach items="${messages}" var="msg">
        <table>
            <tr>
                <td>Author</td>
                <td>${msg.author}</td>
            </tr>
            <tr>
                <td>Title</td>
                <td>${msg.title}</td>
            </tr>
            <tr>
                <td>Body</td>
                <td>${msg.body}</td>
            </tr>
            <tr colspan="2">
                <a href="messageDelete?messageId=${msg.id}">Delete</a>
            </tr>
        </table>
        <hr />
    </c:forEach>
    <a href="messagePost.htm">Post</a>
</body>
</html>